#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <format>
using namespace std;
int main() {
  cout << "### init" << endl;
  string str;
  cout << format("{:47} -> \"{}\"", "string str;", str) << endl;
  string str1 = "012345";
  cout << format("{:47} -> \"{}\"", "string str1 = \"012345\";", str1) << endl;
  string str2 = str1;
  cout << format("{:47} -> \"{}\"", "string str2 = str1;", str2) << endl;
  string str3(6, '#');
  cout << format("{:47} -> \"{}\"", "string str3(6, '#');", str3) << endl;
  string str4(str1);
  cout << format("{:47} -> \"{}\"", "string str4(str1);", str4) << endl;
  string str5("012345");
  cout << format("{:47} -> \"{}\"", "string str5(\"012345\");", str5) << endl;
  string str6(str1, 2);
  cout << format("{:47} -> \"{}\"", "string str6(str1, 2);", str6) << endl;
  string str7(str1, 2, 2);
  cout << format("{:47} -> \"{}\"", "string str7(str1, 2, 2);", str7) << endl;
  string str8("012345", 2);
  cout << format("{:47} -> \"{}\"", "string str8(\"012345\", 2);", str8) << endl;
  string str9({48, '1', '2'});
  cout << format("{:47} -> \"{}\"", "string str9({48, '1', '2'});", str9) << endl;
  string str10(str1.begin() + 1, str1.end() - 1);
  cout << format("{:47} -> \"{}\"", "string str10(str1.begin() + 1, str1.end() - 1);", str10) << endl;

  cout << endl << "### input" << endl;
  cout << "cin >> str;" << endl;
  cout << "getline(cin, str);" << endl;

  cout << endl << "### string" << endl;
  str = "abc";
  cout << format("{:28} -> \"{}\"", "str = \"abc\";", str) << endl;
  cout << format("{:28} -> {}", "str == \"abc\";", str == "abc") << endl;
  cout << format("{:28} -> {}\"", "str > \"abc\";", str > "abb") << endl;
  cout << format("{:28} -> {}", "str < \"abc\";", str < "abd") << endl;
  cout << format("{:28} -> \'{}\'", "str[0];", str[0]) << endl;
  cout << format("{:28} -> \"{}\"", "str + \"def\"", str + "def") << endl;
  str += '#';
  cout << format("{:28} -> \"{}\"", "str += \'#\'", str) << endl;
  str += "abc";
  cout << format("{:28} -> \"{}\"", "str += \"abc\"", str) << endl;
  cout << format("{:28} -> \'{}\'", "str.at(0);", str.at(0)) << endl;
  try {
    char ch = str.at(-1);
  } catch (const out_of_range& error) {
    cout << format("{:28} -> \"{}\"", "str.at(-1);", "out_of_range") << endl;
  }
  cout << format("{:28} -> \'{}\'", "str.front();", str.front()) << endl;
  cout << format("{:28} -> \'{}\'", "str.back();", str.back()) << endl;
  printf("%-28s -> \"%s\"\n", "str.c_str();", str.c_str());
  cout << "str.begin();" << endl;
  cout << "str.end();" << endl;
  cout << format("{:28} -> {}", "str.empty()", str.empty()) << endl;
  cout << format("{:28} -> {}", "\"\"s.empty()", ""s.empty()) << endl;
  cout << format("{:28} -> {}", "str.size()", str.size()) << endl;
  cout << format("{:28} -> {}", "str.length()", str.length()) << endl;
  str.clear();
  cout << format("{:28} -> \"{}\"", "str.clear();", str) << endl;
  str.resize(6, 'a');
  cout << format("{:28} -> \"{}\"", "str.resize(6, '=');", str) << endl;
  str.push_back('b');
  cout << format("{:28} -> \"{}\"", "str.push_back('b');", str) << endl;
  str.pop_back();
  cout << format("{:28} -> \"{}\"", "str.pop_back();", str) << endl;
  str.insert(3, "#");
  cout << format("{:28} -> \"{}\"", "str.insert(3, \"#\");", str) << endl;
  str.erase(1, 2);
  cout << format("{:28} -> \"{}\"", "str.erase(1, 2);", str) << endl;
  str.erase(2);
  cout << format("{:28} -> \"{}\"", "str.erase(2);", str) << endl;
  str.append("?ab");
  cout << format("{:28} -> \"{}\"", "str.append(\"?ab\");", str) << endl;
  str.replace(1, 2, "bc");
  cout << format("{:28} -> \"{}\"", "str.replace(1, 2, \"bc\");", str) << endl;
  cout << format("{:28} -> {}", "str.find(\"ab\");", str.find("ab")) << endl;
  cout << format("{:28} -> {}", "str.find(\"ab\", 2);", str.find("ab", 2)) << endl;
  cout << format("{:28} -> {}", "str.find(\"ab\", 4);", str.find("ab", 4)) << endl;
  cout << format("{:28} -> \"{}\"", "str.substr(1, 3);", str.substr(1, 3)) << endl;
  cout << format("{:28} -> \"{}\"", "str.substr(1);", str.substr(1)) << endl;
  cout << format("{:28} -> {}", "str.starts_with(\"abc\");", str.starts_with("abc")) << endl;
  cout << format("{:28} -> {}", "str.ends_with(\"cab\");", str.ends_with("cab")) << endl;
  cout << format("{:28} -> {}", "stoi(\"123\");", stoi("123")) << endl;
  cout << format("{:28} -> {}", "stoll(\"123345678901\");", stoll("+123345678901")) << endl;
  cout << format("{:28} -> {}", "stod(\"1e4\");", stod("1e4")) << endl;
  cout << format("{:28} -> \"{}\"", "to_string(123);", to_string(123)) << endl;
  cout << format("{:28} -> \"{}\"", "to_string(0.1);", to_string(0.1)) << endl;
  cout << format("{:28} -> \"{}\"", "to_string(1e4);", to_string(1e4)) << endl;
  cout << format("{:28} -> \"{}\"", "to_string(0xFF);", to_string(0xFF)) << endl;
  cout << format("{:28} -> \"{}\"", "to_string(0x1.99999p-4);", to_string(0x1.99999p-4)) << endl;
  cout << format("{:28} -> \"{}\"", "format(\"{}+{}={}\", 1, 2, 3);", format("{}+{}={}", 1, 2, 3)) << endl;
}